package com.tonghe.controller;

import com.tonghe.domain.ResponseResult;
import com.tonghe.domain.dto.ChangeStatus;
import com.tonghe.domain.entity.Recruitment;
import com.tonghe.service.RecruitmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Date:2022/9/8- 09- 08- 22:22
 **/
@RestController
@RequestMapping("/content/recruitment")
public class RecruitmentController {

    @Autowired
    private RecruitmentService recruitmentService;

    /** 分页获取 */
    @GetMapping("/list")
    public ResponseResult getRecruitment(Integer pageSize, Integer pageNum){
        return recruitmentService.getRecruitmentList(pageSize, pageNum);
    }

    /** 获取详情 */
    @GetMapping("/{id}")
    public ResponseResult getRecruitment(@PathVariable Integer id){
        return recruitmentService.getRecruitment(id);
    }

    /** 删除 */
    @DeleteMapping("/{id}")
    public ResponseResult removeRecruitment(@PathVariable Integer id){
        return recruitmentService.removeRecruitment(id);
    }

    /** 新增 */
    // TODO 接口是不是搞错了
    @PostMapping()
    public ResponseResult insertRecruitment(@RequestBody Recruitment recruitment) {
        return recruitmentService.insertRecruitment(recruitment);
    }

    /** 更新状态 */
    @PutMapping()
    public ResponseResult updateRecruitment(@RequestBody Recruitment recruitment) {
        return recruitmentService.updateRecruitment(recruitment);
    }

    /** 改变状态 */
    @PutMapping("/changeRecruitmentStatus")
    public ResponseResult updateRecruitmentStatus(@RequestBody ChangeStatus changeStatus) {
        return recruitmentService.updateRecruitmentStatus(changeStatus);
    }

}
